package com.shujia.core

import org.apache.spark.{SparkConf, SparkContext}

object Demo4Sample {
  def main(args: Array[String]): Unit = {

    /**
      * sample算子
      *
      * 抽样
      */


    val conf = new SparkConf()
      .setMaster("local") //本地运行
      .setAppName("Demo4Sample")

    val sc = new SparkContext(conf)

    val studentRDD = sc.textFile("data/student.txt")


    val sampleRDD = studentRDD.sample(true, 0.1)

    sampleRDD.foreach(println)

  }

}
